function [M, m, med, s, err2] = revival(out_tseries, range_, forecast_horizon)


sh = forecast_horizon(1);
eh = forecast_horizon(end);

d_tseries = out_tseries(range_,:);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%'sdate' & 'edate' & 'n' can be changed
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%the first simulation for compare with history, 
%sdate is the initial state
%sdate+1 is the first simulated time period
sdate = range_(1);

%the last simulation for compare with history, 
%edate is the last historical time period
edate = range_(end);

%length for computing of forecasting properties (1 to 'n' quarters ahead) 
n = forecast_horizon;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

sdate_F = get(tseries(range_,d_tseries(:,2)),'first');
edate_H = get(tseries(range_,d_tseries(:,1)),'last');

if sdate < sdate_F;
    error(['The first simulation starts in ',char(dat2str(sdate_F,2)),', please check the variable ''sdate''']);
end

if edate > edate_H;
    error(['The last historical value ends in ',char(dat2str(edate_H,2)),', please check the variable ''edate''']);
end 

if n > (length(d_tseries(~isnan(d_tseries(:,2)),2))-1)
    error(['parameter ''n'' is too long, please shorten it or change storage period in ''a_driver'', Part II.3.']);
end 
    
d_tseries_H    = d_tseries([(sdate - range_(1) + 1):(edate - range_(1) + 1)],1);

d_tseries_F    =  d_tseries([(sdate - range_(1) + 1):(edate - range_(1) + 1)],[(sdate - sdate_F + 2):(edate - sdate_F+2)]);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%PART II. CALCULATION OF FORECASTING PROPERTIES 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


[a,b] = size(d_tseries_F);
    
M = d_tseries_F - kron(ones(1,b),d_tseries_H);
    
M = M(:);
M = [M;ones(a,1)*NaN];
M = reshape(M,a+1,b);
M = M(2:(n+1),:);
    
    
m    = [];
med  = [];
s    = [];
err2 = [];
    
for i=1:n
    MM   = M(i,~isnan(M(i,:)));
    m    = [m, mean(MM)];
    med  = [med, median(MM)];
    s    = [s, std(MM)];
    err2 = [err2, sum(MM.*MM)/length(MM)];
end

% disp('-------------------------------------------------------------------------------------------');
% disp(' ');
% disp([' # of observations: ',num2str(length(M(i,~isnan(M(1,:))))),' to ',num2str(length(M(i,~isnan(M(n,:)))))]);
% disp(['Statistical properties of forecasting 1 to ',num2str(n),' quarters ahead']);
% disp(' ');
% disp([['mean           | ';'median         | ';'std            | ';'err2           | '] [num2str([m;med;s;err2])]]);
% disp(' ');
% disp('-------------------------------------------------------------------------------------------');   


